from pprint import pprint

from celery import Celery

broker_url_redis = 'redis://192.168.31.100:6379/0'
backend = 'redis://192.168.31.100:6379/1'
app = Celery('tasks',
             broker=broker_url_redis,
             backend=backend)
@app.task(track_started=True)
def add(x, y):
    pprint(f"x is {x},y is {y} ,add is {x+y}")
    return x + y


@app.task(bind=True)
def dump_context(self, x, y):
    print('Executing task id {0.id}, args: {0.args!r} kwargs: {0.kwargs!r}'.format(
            self.request))


if __name__ =="__main__":
    app.start()